package com.kika.obwiki.controller;

import com.kika.obwiki.resp.StatisticResp;
import com.kika.obwiki.service.IEbookSnapshotService;
import com.kika.obwiki.resp.CommonResp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author cr
 * @since 2025-06-22
 */
@RestController
@RequestMapping("/ebookSnapshot")
public class EbookSnapshotController {
  @Resource
  private IEbookSnapshotService ebookSnapshotService;

  /**
   * 获取统计数据
   * 
   * @return CommonResp<List<StatisticResp>>
   */
  @GetMapping("/getStatistic")
  public CommonResp<List<StatisticResp>> getStatistic() {
    List<StatisticResp> statisticResp = ebookSnapshotService.getStatistic();
    CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
    commonResp.setContent(statisticResp);
    return commonResp;
  }

  /**
   * 获取近30天快照统计数据
   * 
   * @return CommonResp<List<StatisticResp>>
   */
  @GetMapping("/get30Statistic")
  public CommonResp<List<StatisticResp>> get30Statistic() {
    List<StatisticResp> statisticResp = ebookSnapshotService.get30Statistic();
    CommonResp<List<StatisticResp>> commonResp = new CommonResp<>();
    commonResp.setContent(statisticResp);
    return commonResp;
  }
}
